<?php

namespace App\Admin\Tables;

use App\Admin\Repositories\User;
use Dcat\Admin\Grid;
use Dcat\Admin\Grid\LazyRenderable;

class UserTable extends LazyRenderable
{
    public function grid(): Grid
    {
        // 获取外部传递的参数
//        $id = $this->id;

        return Grid::make(new User(), function (Grid $grid) {
            $grid->column('id')->sortable();
            $grid->column('avatar','头像')->image('',50,50);
            $grid->column('nickname','微信昵称');
            $grid->column('mobile','手机号');
            $grid->column('is_auth','是否核销人员')->radio(['否','是'],true)->label(['default','success']);

            $grid->quickSearch(['id', 'nickname', 'mobile']);

            $grid->paginate(10);
            $grid->disableActions();

            $grid->filter(function (Grid\Filter $filter) {
                $filter->panel()->expand(true);
                $filter->like('nickname','微信昵称')->width(3);
                $filter->like('mobile','手机号')->width(3);
                $filter->equal('is_auth','是否核销人员')->select(['否','是'])->width(3);
            });
        });
    }
}
